//
//  WTMainViewController.swift
//  WTSinaWeibo
//
//  Created by  Wellim on 16/6/24.
//  Copyright © 2016年  Wellim. All rights reserved.
//

import UIKit

class WTMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

       // 自定义tabBar
        let tabBar = WTTabBar()
        // 通过KVC 给只读属性赋值
        setValue(tabBar, forKey: "tabBar")
        
        //设置代理对象
         tabBar.WTdelegate = self
        
        
       //添加子控制器
        addChildViewController(WTHomeController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(WTMessageController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(WTDiscoverController(), title: "发现", imageName: "tabbar_discover")
        
        addChildViewController(WTProfileController(), title: "我", imageName: "tabbar_profile")
        
        
    }
    
    //tabbar_profile  tabbar_profile_selected
   
    func addChildViewController(Vc: UIViewController,title: String,imageName: String) {
        
        
        Vc.title = title
        
        Vc.tabBarItem.image = UIImage.init(named: imageName)
        
        
        Vc.tabBarItem.selectedImage = UIImage.init(named: "\(imageName)_selected")
        
        let nav = UINavigationController(rootViewController: Vc)
        
        addChildViewController(nav)
        
        
        
        }


    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

extension WTMainViewController :WTTabBarDelegate{


    func composeButtonClick() {
        
     
        let nav = UINavigationController(rootViewController: WTComposeViewController())
        
        presentViewController(nav, animated: true, completion: nil)
        
        
    
    }

}


